package net.babypai.widget;

import net.babypai.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

/**
 * @author fiker
 * 
 */
public class BpDialogView extends RelativeLayout {

	private TextView itemTitle,viewText;
	private LinearLayout viewLayout,dialog_title_panel,dialog_view_panel;
	private Button bt_yes, bt_no;

	public BpDialogView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public BpDialogView(Context context) {
		super(context);
	}

	@Override
	protected void onFinishInflate() {
		dialog_title_panel = (LinearLayout) findViewById(R.id.dialog_title_panel);
		itemTitle = (TextView) findViewById(R.id.dialog_title);
		viewText = (TextView) findViewById(R.id.dialog_view_text);
		viewLayout = (LinearLayout) findViewById(R.id.dialog_view_layout);
		dialog_view_panel = (LinearLayout) findViewById(R.id.dialog_view_panel);
		bt_yes = (Button) findViewById(R.id.dialog_yes);
		bt_no = (Button) findViewById(R.id.dialog_no);

		super.onFinishInflate();
	}

	public void setTitle(int TitleId) {
		this.itemTitle.setText(TitleId);
	}

	public void setTitle(CharSequence title) {
		this.itemTitle.setText(title);
	}
	
	public void setNoTitle(){
		dialog_title_panel.setVisibility(View.GONE);
	}
	
	public void setNoView(){
		dialog_view_panel.setVisibility(View.GONE);
	}

	public void setViewText(int textId){
		this.viewText.setText(textId);
		this.viewLayout.setVisibility(View.GONE);
	}

	public void setViewText(CharSequence title) {
		this.viewText.setText(title);
		viewLayout.setVisibility(View.GONE);
	}
	
	public void setViewLayout(View view){
		this.viewText.setVisibility(View.GONE);
		this.viewLayout.setVisibility(View.VISIBLE);
		viewLayout.addView(view);
	}

	public void HiddenButton(int ButtonId) {
		if (ButtonId == R.id.dialog_yes) {
			this.bt_yes.setVisibility(GONE);
		} else if (ButtonId == R.id.dialog_no) {
			this.bt_no.setVisibility(GONE);
		}
	}
}
